<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$merchid=$this->checklogin();
if($_RQ['op']=='main'){
	$return['list']=array();
	$return['params']['type']=1;
	set_html('title','押金记录');
	exi($return);
}
if($_RQ['op']=='list'){	
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_weishopwater_yalog',$params,array($pindex,$psize),$total,'','','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['gtitle']=pdo_getcolumn('jy_weishop_goods_group',array('id'=>$item['gid']),'title');
			$item['statustitle']=$this->yalog_status[$item['status']];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'id','title'=>'ID','type'=>'string'),
			array('name'=>'fee','title'=>'金额','type'=>'string'),
			array('name'=>'statustitle','title'=>'状态','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'string'),
		),'action'=>array(
			//array('type'=>'post','action'=>'pay','title'=>'支付'),
		)
		),
	);
	if($_SESSION['os']=='mobile'){
	}else{
		$return['htmls']=$htmls;
	}
	exi($return);
}
if($_RQ['op']=='apply'){
	$logid=intval($_RQ['logid']);
	if(!$logid){
		exi('请先选择订单！','error');
	}
	$return['log']=$this->pdo_get('yalog',array('id'=>$logid,'uniacid'=>$_SESSION['uniacid']));
	$return['log']['statustitle']=$this->yalog_status[$return['log']['status']];
	exi($return);
}
if($_RQ['op']=='applyinfo'){
	$logid=intval($_RQ['logid']);
	if(!$logid){
		exi('请先选择订单！','error');
	}
	$return['log']=$this->pdo_get('yalog',array('id'=>$logid,'uniacid'=>$_SESSION['uniacid']));
	$return['log']['statustitle']=$this->yalog_status[$return['log']['status']];
	exi($return);
}
if($_RQ['op']=='checkapply'){
	$post=get_postdata();
	$logid=intval($post['id']);
	if(!$logid){
		exi('请先选择订单！','error');
	}
	$log=$this->pdo_get('yalog',array('id'=>$logid,'uniacid'=>$_SESSION['uniacid']));
	if($log['status']!=1){
		exi('该押金订单不支持退！','error');
	}
	$this->pdo_update('yalog',array('status'=>3),array('id'=>$logid,'uniacid'=>$_SESSION['uniacid']));
	exi('申请成功！请耐心等待管理员审核！','','main');
}